package com.mxpio.erp.common.plm.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;

@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "MB_ERP_PLM_PROJECT_PROBLEM")
@Schema(description = "项目任务问题库")
public class ProjectProblem extends BaseEntity {


    private static final long serialVersionUID=1L;
    @Id
    @Column(name = "QUESTION_CODE_")
    @Generator(policy = ResCodeGeneratorPolicy.class)
    @Schema(description = "问题编码")
    private String questionCode;

    @Column(name = "QUESTION_NAME_")
    @Schema(description = "问题名称")
    private String questionName;

    @Column(name = "QUESTION_TYPE_")
    @Schema(description = "问题分类")
    @Dict(dicCode = "problemCode" , dicEntity = ProjectProblemSort.class ,dicText = "problemName")
    private String questionType;

    @Column(name = "PRO_NAME_")
    @Schema(description = "项目名称")
    private String proName;

    @Column(name = "STATUS_")
    @Schema(description = "状态")
    @Dict(dicCode = "ERP_PLM_TASK_PROBLEM_STATUS")
    private String status;

    @Column(name = "PRO_CODE_")
    @Schema(description = "项目编码")
    private String proCode;

    @Column(name = "TASK_CODE_")
    @Schema(description = "任务编码")
    private String taskCode;

    @Column(name = "TASK_NAME_")
    @Schema(description = "任务名称")
    private String taskName;

    @Column(name = "QUESTION_SOURCE_")
    @Schema(description = "问题来源")
    @Dict(dicCode = "ERP_PLM_PROJECT_PROBLEM_SOURCE")
    private String questionSource;

    @Column(name = "DISCOVERER_")
    @Schema(description = "发现人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String discoverer;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd  HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd  HH:mm:ss")
    @Column(name = "DISCOVER_TIME_")
    @Schema(description = "发现时间")
    private String discoverTime;

    @Column(name = "SERVERITY_")
    @Schema(description = "严重程度")
    @Dict(dicCode = "ERP_PLM_PROJECT_PROBLEM_SEVERITY")
    private String severity;

//    @Column(name = "TRACKER_")
//    @Schema(description = "跟踪人")
//    private String tracker;

    @Column(name = "QUESTION_LEADER_")
    @Schema(description = "负责人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String questionLeader;

    /**计划解决时间*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "计划解决时间")
    @Column(name = "PLAN_SOLVE_TIME_")
    private java.util.Date planSolveTime;

    @Column(name = "PLAN_LIBERATION_",columnDefinition = "TEXT")
    @Schema(description = "计划解决方案")
    private String planLiberation;

    /**实际解决时间*/
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "实际解决时间")
    @Column(name = "REAL_SOLVE_TIME_")
    private java.util.Date realSolveTime;

    @Column(name = "REAL_LIBERATION_",columnDefinition = "TEXT")
    @Schema(description = "实际解决方案")
    private String realLiberation;

    @Column(name = "REACH_")
    @Schema(description = "影响范围")
    @Dict(dicCode = "ERP_PLM_PROJECT_PROBLEM_REACH")
    private String reach;

    @Column(name = "DESC_",columnDefinition = "TEXT")
    @Schema(description = "问题描述")
    private String desc;

    @Column(name = "REASON_",columnDefinition = "TEXT")
    @Schema(description = "发生原因")
    private String reason;

    @Column(name = "DEAL_FILE_")
    @Schema(description = "处理附件")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    private String dealFile;

    @Transient
    @Schema(description = "拒绝原因")
    private String refuseReason;
}
